def write_file(filename, content):
    with open(filename, 'w', encoding='utf-8') as f:
        f.write(content)


def read_file(filename):
    try:
        with open(filename, 'r', encoding='utf-8') as f:
            return f.read()
    except UnicodeDecodeError:
        # 如果 UTF-8 解码失败，尝试使用 'gbk' 编码
        with open(filename, 'r', encoding='gbk') as f:
            return f.read()
